package main

import (
	"whoscored/util/mysql"
	"fmt"
	"strings"
	"whoscored/util/boltdb"
)

func main()  {
	sql:="select * from qt_match where startAt>='2016-01-01' order by startAt"
	sql2:="update qt_match set weather=?,temperatureMin=?,temperatureMax=? where id=?"
	matchs:=mysql.FindAll(sql)
	i:=0
	for _,v:=range matchs {
		boltdb.Get("header-2016",v["league"].(string),v["id"].(string), func(data string) {
			s:=strings.Split(data,"^")
			if len(s)==26{
				a:=s[19]
				b:=s[20]
				if a!=""&&strings.Contains(a,"℃"){
					a=strings.Replace(a,"℃","",-1)
					ss:=strings.Split(a,"～")
					if len(ss)>1{
						mysql.UpdateOrDelete(sql2,b,ss[0],ss[1],v["id"])
						fmt.Println(i)
						i++
					}

				}

			}
		})

	}
}